﻿using System;

namespace UtilZ.Dotnet.Ex.Json
{
    /// <summary>
    /// json序列特性
    /// </summary>
    public class JsonPropertyAttribute : JsonBaseAttribute
    {
        private static readonly JsonPropertyAttribute _default;
        /// <summary>
        /// 
        /// </summary>
        public static JsonPropertyAttribute Default
        {
            get { return _default; }
        }

        static JsonPropertyAttribute()
        {
            _default = new JsonPropertyAttribute(string.Empty);
        }

        private readonly string _memberName;
        /// <summary>
        /// 序列化后成员名称
        /// </summary>
        public string MemberName
        {
            get { return _memberName; }
        }


        /// <summary>
        /// 序列化时值转换器类型
        /// </summary>
        public Type ValueConverterType { get; set; } = null;

        /// <summary>
        /// 成员忽略器类型
        /// </summary>
        public Type MemberIgnoreerType { get; set; } = null;

        /// <summary>
        /// 描述
        /// </summary>
        public string Description { get; set; } = null;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="memberName">序列化后成员名称</param>
        public JsonPropertyAttribute(string memberName)
            : base(int.MinValue)
        {
            this._memberName = memberName;
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="memberName">序列化后成员名称</param>
        /// <param name="order">序列化顺序</param>
        public JsonPropertyAttribute(string memberName, int order)
            : base(order)
        {
            this._memberName = memberName;
        }



    }
}
